package wc;

import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.Map.Entry;

public class Main {
	public static void main(String[] args) throws IOException{
		String in=null;
		String out=null;
		int m=0,n=0;
		Scanner sc =new Scanner(System.in);	
		String s = sc.nextLine();
		String[] arg = s.split(" +");//用空格作为分割

		for(int i=0;i<arg.length;i++){
			if("-i".equals(arg[i])){//-i 参数设定读入的文件路径
				i++;
				in=arg[i];
			}
			if("-m".equals(arg[i])){//-m 参数设定统计的词组长度
				i++;
				m=Integer.parseInt(arg[i]);
			}
			if("-n".equals(arg[i])){//-n参数设定输出的单词数量
				i++;
				n=Integer.parseInt(arg[i]);
			}
			if("-o".equals(arg[i])){//-o 参数设定生成文件的存储路径
				i++;
				out=arg[i];
			}
		}
		String path="D:\\soft-ware\\PersonalProject-Java\\201621123037qinyu\\WordCount_2\\"+in;
		String save="D:\\soft-ware\\PersonalProject-Java\\201621123037qinyu\\WordCount_2\\"+out;
		File file=new File();		
		ArrayList<String> line=new ArrayList<>();
		line=file.readfile(path);
		Count count=new Count(line);
		int CountChars=count.CountChars();
		int CountWords=count.CountWords();
		int CountLine=count.CountLine();
		ArrayList<Entry<String, Integer>> wordtop=count.WordTop(n,CountWords);
		Map<String,Integer> CountPhrase=count.CountPhrase(m);
	
		
		file.writefile(save, CountChars, CountWords, CountLine, wordtop, CountPhrase);
	}

}
